package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import easier.app.x.CommonCode;

public class MainActivity77 extends AppCompatActivity {

    private TextView mText;
    private Button mButton;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity77.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main77 );
        initView();
        initViewAction();
    }

    private void initView() {

        mText = (TextView) findViewById( R.id.text );
        mButton = (Button) findViewById( R.id.button );
    }

    private void initViewAction() {

        if ( CommonCode.areNotificationsEnabled( this ) ) {
            mText.setText( "已打开" );
        } else {
            mText.setText( "已关闭" );
        }

        mButton.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                CommonCode.openNotificationSetting( v.getContext() );
            }
        } );
    }

    @Override
    protected void onResume() {

        super.onResume();

        if ( CommonCode.areNotificationsEnabled( this ) ) {
            mText.setText( "已打开" );
        } else {
            mText.setText( "已关闭" );
        }
    }
}